﻿<%@ Page Title="" Language="C#" validateRequest="false" AutoEventWireup="true" CodeBehind="Content.aspx.cs" Inherits="Slja.WEB.Design.Content" %>
<%@ Import Namespace="Slja.Lib" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
         body{font-size:12px;}
        #MainDTable,#tblFilepack
        {
            border-top: #a9cbee 1px solid;
            border-left: #a9cbee 1px solid;
        }
       #MainDTable td, #MainDTable th,#tblFilepack td,#tblFilepack th
        {
            border-top: 0;
            border-left: 0;
            border-bottom: #a9cbee 1px solid;
            border-right: #a9cbee 1px solid;
            padding:0px;
        }
         #MainDTable table td, #tblFilepack table td
         {
              padding:1px;
         }
        #imgtbl
        { border: #a9cbee 1px solid;  
          margin:0;         
        }  
         #imgcontainer  
        {  border-right: #a9cbee 1px solid;  border-bottom: #a9cbee 1px solid;  border-left: #a9cbee 1px solid;  
          margin:0;         
        }   
       .txtIn{width: 90%;}
       .smpbtn{width:20px;height:20px;cursor:pointer;}
        .cation
        {
            width: 300px;
        }
       
        #InputTbl{border:#a9cbee 1px solid;background-color:#f6f9fe;}
        #imgTagList{list-style:none;*zoom:1;overflow:auto;margin:2px;}
        #imgTagList li{float:left;}
        #imgTagList li a{margin:auto 2px auto 2px;}
        .curIdxTag{font-weight:bold;color:Red;font-size:12px;text-decoration:underline;}
        .otherIdxTag{font-weight:normal;color:inherit;font-size:12px;cursor:pointer;text-decoration:underline;}
        .imgoppanel{background-color:#f6f9fe;padding:0;}
        .imgoppanel td{padding:0;margin:0;height:20px;}
    </style>
     <script type="text/javascript" src="../inc/Dialog.js"></script>
      <script type="text/javascript" src="../inc/JS/Offen/public.js"></script>
  <script type="text/javascript" src="../inc/JS/jquery.js"></script>
    <script type="text/javascript" src="../inc/JS/jquery.xml2json.js"></script>
    <script type="text/javascript" src="../inc/JS/Origine/DnmcTable.js"></script>
    <script type="text/javascript" src="../inc/JS/Offen/DesignJS.js"></script>
     <script type="text/javascript" src="../inc/JS/JsonSerial.js"></script>
    
</head>
<body style="margin:1px;padding:0;">
    <form id="form1" runat="server" enctype="multipart/form-data">

    
    <table border="0">
        <tr>
            <td width="60%" valign="top" style="padding:0;">
            <table width="100%">
                <tr>
                    <td>
                        <table width="100%" id="InputTbl" border="0">
                            <tr>                        
                                <td>
                                    <div>区域：</div><asp:TextBox runat="server" ID="tbxRegion"></asp:TextBox>
                                </td>
                        
                                <td>
                                     <div> 店名：</div><asp:TextBox runat="server" ID="tbxShop"></asp:TextBox>
                                </td>
                        
                                <td>
                                    <div>  ID号：</div><asp:TextBox runat="server" ID="tbxPrjID"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                        
                                <td>
                                     <div> 日期：</div><asp:TextBox runat="server" ID="tbxDate"></asp:TextBox>
                                </td>                     
                                <td>
                                  <div>  设计：</div><asp:TextBox runat="server" ID="tbxDesigner"></asp:TextBox>
                                </td>                        
                                <td>  <div> 项目名称：</div>
                                        <asp:TextBox runat="server" ID="tbxPrjName"></asp:TextBox>
                                </td>
                            </tr>
                            <tr><td colspan="3">
                               <%-- 效果图：<input type="file" id="file1" runat="server" accept="*.jpg|*.bmp" onchange="fileImgChange(this);" />--%>
                               <asp:HiddenField ID="hdfID" runat="server" />
                            </td></tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td  align="center">
                        <asp:Button runat="server" ID="btnQuery" Text="查询" OnClientClick="return false;" style="display:none;" />&nbsp;
                        <asp:Button runat="server" ID="btnSave" Text="新增" OnClientClick="if(validForm()){SerialXml();} else{return false;}"  Visible="false" OnClick="btnSave_click" /> <%----%>
                        &nbsp;<asp:Button runat="server" ID="btnEdit" Text="保存" Visible="false"  OnClientClick="if(validForm()){SerialXml();} else{return false;}" OnClick="btnEdit_click" />
                        <asp:Button runat="server" ID="btnDel" Text="删除" Visible="false"  OnClientClick="return confirm('真的要删除么？');" OnClick="btnDel_click" />
                        <asp:HiddenField runat="server" ID="hdfImgPath" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                </tr>
                <tr>
                    <td >
                        <table border="0" id="MainDTable" width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <th width="6%">
                                    <%--<input id="MainDTableBtnAdd" class="smpbtn" value="+" type="button" />
                                    <input id="MainDTableBtnDlt" class="smpbtn" value="--" type="button"  title="删除选中的行" />--%>
                                      <a id="MainDTableBtnAdd" class="smpbtn"  title="添加"> + </a>
                                      <a id="MainDTableBtnDlt" class="smpbtn"  title="删除选中的行"> -- </a>
                                </th>
                                <th width="25%">
                                    安装内容
                                </th>
                                <th width="25%">
                                    尺寸
                                </th>
                                <th width="25%">
                                    画面
                                </th>
                                 <th width="20%">
                                    尺寸
                                </th>
                            </tr>
                            <tr dname='tmplt' style="display: none;">
                                <td>
                                    <input type="checkBox" dname="chx" />
                                </td>
                                <td>
                                    <input type="text" dname="aznr"  class="txtIn" />
                                </td>
                                <td>
                                    <input type="text" dname="azcc"  class="txtIn" />
                                </td>
                                <td colspan="2" style="border:0;">
                                    <table border="0" id="ChildDTable" width="100%"  cellpadding="0" cellspacing="0">
                                
                                        <tr>
                                            <th style="width:12%;">                     
                                                <a id="ChildDTableBtnAdd" class="smpbtn" onclick="ptbl(this).dnmcObj.Add();" title="添加"> + </a>
                                                <a id="ChildDTableBtnDlt" class="smpbtn" onclick="ptbl(this).dnmcObj.Delete();" title="删除选中的行"> -- </a>
                                            </th>
                                            <th colspan="2">
                                   
                                            </th>
                                        </tr>
                                        <tr dtag="tmplt" style="display: none;">
                                            <td>
                                                <input type="checkBox" dtag="chy" />
                                            </td>
                                            <td>
                                                <input type="text" dtag="hmmc" class="txtIn" />
                                            </td>
                                            <td>
                                                <input type="text" dtag="hmcc" class="txtIn" />
                                            </td>
                                        </tr>
                                    </table>
                                    <input id="ChildDTableHdf" type="hidden" dname="ChildHdf" />
                                </td>
                            </tr>
                        </table>
                        <asp:HiddenField runat="server" ID="MainDTableHdf" />
                        <asp:PlaceHolder runat="server" ID="plhFilePack"> 
                            <br />                           
                             <table border="0" id="tblFilepack" width="100%"  cellpadding="0" cellspacing="0">
                                <tr>
                                   <th width="6%"><a class="smpbtn" onclick="zOpen();" title="添加文件">+</a>
                                        <a class="smpbtn" title="删除选中的行" onclick="DeleteFilepack();">--</a>
                                   </th> <th  width="30%">文件</th><th width="10%">大小</th><th>备注</th><th width="10%">上传时间</th>
                                   <asp:Repeater runat="server" ID="RepeaterFilepacks">
                                    <ItemTemplate>
                                        <tr dname='datarow'>
                                            <td><input type="checkbox" id="chx" value='<%#Eval("ID") %>' /></td>
                                            <td><a href='<%#Eval("FilepackPath") %>'><%#Eval("FilepackName") %></a></td>
                                            <td><%#Slja.Lib.Utility.ConvertFileLength(Eval("FilePackSize") == DBNull.Value ? 0.0m : (decimal)Eval("FilePackSize"))%></td>
                                            <td><%#Eval("Memo") %></td>
                                            <td><%#Eval("UploadTime") %></td>
                                        </tr>
                                    </ItemTemplate>
                                   </asp:Repeater>
                                </tr>                                
                             </table>
                        </asp:PlaceHolder>
                    </td>
                </tr>
            </table>
            
           </td>
           <td width="39%" valign="top" style="padding-top:3px;">
             <table id="imgtbl" width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr class="imgoppanel" align="center">
                    <td align="center"><ul id="imgTagList"></ul></td>
                    <td width="20%" id="tdeditimg"><a class="smpbtn" onclick="AddImg();" style="cursor:pointer;" title="上传新图片">+</a> &nbsp;&nbsp;&nbsp;&nbsp;
                        <a class="smpbtn" onclick="DelImg();"  style="cursor:pointer;"  title="删除图片">--</a></td>                
                </tr>
                <tr >
                    <td colspan="2" align="center">                        
                        <input type="hidden" id="hdfCurrentIdx" value="0" />
                        <asp:HiddenField runat="server" ID="hdfImgData" Value="[]" />
                        <div id="divHide" style=""></div>
                    </td>
                </tr>
             </table>  
             <div id="imgcontainer">
               <img id="imgView" alt="图片" runat="server" style="width:450px;" src=""/>
               <div id="imgPreview" style="width:450px;height:400px;"> </div>   
              </div>       
           </td>
        </tr>
 
    </table>
    
    
    <script type="text/javascript">
        function getId(id) {
            return $("#" + id);
        }
        function fileImgChange(fl) {
            if (fl.value) {
               // alert(fl);
                getId("imgView").attr("src", fl.value+"?rdm="+Math.random());
                $("#imgPreview").show();
                getId("imgView").hide();
                PreviewImage(fl);
            }
        }
       
        function ptbl(btn) {

            var ptable;
            ptable = btn.parentNode.parentNode.parentNode.parentNode;
            return ptable
        }
        //options.onNewRow(tr)
        //options.AfterAdd(dnmcRowId)
        //options.afterShowRow()
        //options.beforeDeleteRow()
        //options.afterDeleteRow();
        //options.AfterDeSeri()
        var mOpt = {};
        mOpt.onNewRow = function (tr) {
            var opt = {};
            opt.region = tr;
            var ctb = $("#ChildDTable", opt.region);
            var dnmcTChild = new DnmcTable("ChildDTable", "chy", "#", opt, "dtag");
            ctb[0].dnmcObj = dnmcTChild; //对象关联js类
            DnmcTable.Ini(dnmcTChild);
        }
        mOpt.onBeforeRowSerial = function (tr) {         
            var dnmcTable = $("#ChildDTable", tr);
            dnmcTable[0].dnmcObj.Serialize();
        }
        mOpt.AfterDeSeri = function (tr) {          
            var dnmcTable = $("#ChildDTable", tr);
            dnmcTable[0].dnmcObj.DeSerialize();
        }

      
        function SerialXml() {
            dnmcTMain.Serialize();
        }
       
        function loadFormRight() {
            var editable = "TRUE" == "<%=Editable%>".toUpperCase();
            if (!editable) {
                $("input[type=text]", "#InputTbl").each(function () { this.disabled = true; });
                //$("a.smpbtn", "#MainDTable").each(function () { this.style.display="none"; }); 
                $("tr", "#MainDTable").each(function () { this.childNodes[0].style.display = "none"; });
                $("input[type=text]", "#MainDTable").each(function () { this.disabled = true; });
                $("#tdeditimg").hide();
                $("tr", "#tblFilepack").each(function () { this.childNodes[0].style.display = "none"; });
            }
        }
        function validForm() {

            if (!$.trim($("#tbxRegion").val())) {
                alert("请输入区域"); return false;
            }
            if (!$.trim($("#tbxShop").val())) {
                alert("请输入店名"); return false;
            }
            if (!$.trim($("#tbxPrjID").val())) {
                alert("请输入ID号"); return false;
            }
            var yn = isDate($("#tbxDate").val());
            if (!yn) {
                alert("日期格式不正确");
                return false;
            }           
            return true;
        }
        function LoadDefaultView() {
            var hdfimgData = $("#hdfImgData");
            if (hdfimgData.val() != "" && hdfimgData.val() != "[]") {//debugger;
                try {
                    ImgInit();
                } catch (e) { }
            } else {
                $("#imgPreview").hide();
                $("#imgView").attr("src", "/inc/images/space.gif").show();
            }
            //载入权限控制
            loadFormRight();
        }
        function zOpen() {
            
            //项目Id
            var Id = $("#hdfID").val();
            var shop= $("#tbxShop").val();
            var region=$("#tbxRegion").val();
            var prjid=$("#tbxPrjID").val();

            //调用div弹出窗口
            var diag = new Dialog("Diag2");
            diag.Width = 620;
            diag.Height = 400;
            diag.Title = "操作窗口";
            diag.URL = "/design/upload.aspx?id=" + Id + "&region=" + region + "&shop=" + shop + "&prjid=" + prjid + "&rdm=" + Math.random();
            diag.OKEvent = callba;    //点击确定后调用的方法
            diag.CancelEvent = callba;
            diag.show();
        }

        function callba(obj) {
            //调用ajaxpro取得数据列表
            var list = Slja.WEB.Design.Content.GetFilepackList($("#hdfID").val()).value;
            var tbl = $("#tblFilepack");
            $("tr[dname=datarow]", tbl).each(function () { $(this).remove(); });
            var tr, dr;
            
            for (var i = 0; i < list.length; i++) {
                tr = ""
                dr = list[i];
                tr += "<tr dname='datarow'>";
                tr += "<td><input type='checkbox' id='chx' value='" + dr["ID"].toString() + "' /></td>"; //checkbox列
                tr += "<td><a href='"+dr["FilepackPath"]+"'>"+dr["FilepackName"]+"</a></td>";//文件链接列
                tr += "<td>"+dr["FilepackSize"].toString()+"</td>"; //文件大小
                tr += "<td>"+dr["Memo"]+"</td>"; //文件大小
                tr += "<td>" + dr["UploadTime"].Format("yyyy-MM-dd hh:mm:ss") + "</td>"; //上传时间
                tr += "</tr>";
                tbl.append($(tr));
            }
        }
        var dnmcTMain = new DnmcTable("MainDTable", "chx", '#', mOpt, "dname");
        DnmcTable.Ini(dnmcTMain);
        LoadDefaultView();
    </script>
</form>
</body>
</html>
  